package com.example.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: HelloSprintBoot
 * Package: IntelliJ IDEA
 * Description:
 *
 * @Author 谷京京
 * @Create 2023/10/21 9:50
 * @Version 1.0
 */
//访问地址: 类路径+方法路径
//路径也可以写多层, 比如"/hello/a"
//'/'可以省略, 但是在企业开发中要加,
@RequestMapping("/hello")
@RestController
public class HelloController {
    @RequestMapping(value = "/sayHi")
    //@RequestMapping支持所有请求GET,POST,PUT,DELETE...
    //如果想指定请求方式, 就这样写: @RequestMapping(value = "/sayHi",method = RequestMethod.GET)
    //如果不指定, 就直接写路径
    public String sayHi(){
        return "hi,Spring";
    }
    //@GetMapping 表示只支持 GET 类型的请求
    @GetMapping("/sayHi2")
    public String sayHi2(){
        return "hi,Spring";
    }
    @RequestMapping("/sayHello")
    public String sayHello() {
        return "hello world";
    }

}
